<script type="text/javascript" src="${createLinkTo(dir: 'js/jquery', file: 'jquery.form.js')}"></script>
<script type="text/javascript" src="${createLinkTo(dir: 'js/jquery', file: 'jquery.FCKEditor.js')}"></script>

<script type="text/javascript">
  $(function() {
    $('#content').fck({path: '/yuying/fckeditor/',  toolbar:'Basic', height:200 });
    $('#addExp').submit(function(){
      $(this).ajaxSubmit({
       complete: function(r){
         var $tabs = $('#tabs').tabs();
         $tabs.tabs('load', 5);
       }
      });
      return false;
    });

    $('.paginateButtons  a').click(function() {
      var $tabs = $('#tabs').tabs();
      $tabs.tabs('url', 5, this.href)
      $tabs.tabs('load', 5);
      return false;
    });
  });
  
  function deleteisay(t,rid) {
      if (confirm("确定删除该体会？")) {
          $.get("${createLink(controller:'experience',action:'ajaxdelete')}",{target:t, id:rid}, function(data) {
              chkDeleteCB(data,rid);
          });
      }
  }
  function chkDeleteCB(d,rid) {
      if (d=="1") {
          $("#isay"+rid).fadeOut("slow", function() {
              $(this).remove();
              if ($(".gbt").length==0) {
                  $("#isayD").html('<div class="isayNoMsg">没有任何体会。</div>');
              }
          });
      } else if (d=="-1") {
          alert("对不起，请先登录。");
      } else if (d=="-2") {
          alert("错误，要删除的心得体会不存在。");
      }
  }
  

</script>

<div class="experience">
  <div id="growAddBtn" class="optBtnDiv">
    <a href="#" onclick="$('#expAddDiv').slideDown('slow')">(+) 增加我的育婴心得</a>
  </div>
  <div id="expAddDiv" class="addFormDiv hidden">
    <g:form controller="experience" action="save" name="addExp">
      <table cellspacing="0" cellpadding="0" class="composeT">
        <tr class="prop">
          <td class="name">
            标题：
          </td>
          <td class="value">
            <input type="text" id="title" name="title"/>
          </td>
        </tr>
        <tr class="prop">
          <td class="name">
            内容：
          </td>
          <td class="value">
            <textarea name="content" id="content" class="fck"></textarea>
          </td>
        </tr>
        <tr class="prop">
          <td class="name">
          </td>
          <td class="submit">
            <input type="submit"  class="btnGrey" value="发送" />
            <a href="#" onclick="$('#expAddDiv').slideUp('slow')">取消</a>
          </td>
        </tr>
      </table>

    </g:form>
  </div>
  <div id="isayD">
    <g:each in="${experienceList}" var="experience">
    <table cellspacing="0" cellpadding="0" class="gbt" id="isay${experience.id}">
      <tr>
        <td rowspan="3" class="gbth">
          <g:link controller="b" action="show" id="${experience.baby.id}">
            <cms:headImg baby="${experience.baby}"/>
          </g:link>
        </td>
        <td class="gbbmn">
          <g:link controller="b" action="show" id="${experience.baby.id}">
            <b>
              ${experience.baby.person.username}
            </b>
           </g:link>
           说：
        </td>
        <td class="gbbmt">
          <g:formatDate date="${experience.dateCreated}" format="yyyy年MM月dd日 HH:mm"/>
        </td>
      </tr>
      <tr>
        <td colspan="2" class="gbbmc">
          <div class="gbbmcOF" style="width: 404.4px">
            <p>${experience.title}</p>
            ${experience.content}
          </div>
        </td>
      </tr>
      <tr>
        <td colspan="2" class="gbbma">
          <ul>
            <li>
              ▪<a href="${createLink(controller:'b',action:'show', id:experience.baby.id)}" class="gbbmar">回复</a>
            </li>
            <li>
              ▪<a href="javascript:deleteisay('user',${experience.id})" class="gbbmar">删除</a>
            </li>
          </ul>
        </td>
      </tr>
    </table>
    </g:each>
    <div class="paginateButtons">
        <g:paginate total="${total}" />
    </div>
  </div>
</div>

